/**
Zeke Elder - zbe@andrew.cmu.edu
Amal Chemmany - achemman@andrew.cmu.edu
Nishant Kumar - nkumar1@andrew.cmu.edu
15-637
4/2/2012
 **/

package edu.cmu.fithub.actions;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import edu.cmu.fithub.controller.Action;
import edu.cmu.fithub.db.DBHelper;
import edu.cmu.fithub.db.bean.Exercise;
import edu.cmu.fithub.db.bean.Schedule;
import edu.cmu.fithub.db.bean.Workout;
import edu.cmu.fithub.db.bean.User;
import edu.cmu.fithub.db.bean.WorkoutDisplay;

public class DisplayAddWorkoutAction extends Action {

	public DisplayAddWorkoutAction() {
	}

	public String getName() {
		return "displayAddWorkout.do";
	}

	public String perform(HttpServletRequest request) {

		List<String> errors = new ArrayList<String>();
		request.setAttribute("errors", errors);

		Session dbSession = DBHelper.getSessionFactory().openSession();

		// get list of exercises to populate dropdown
		List<Exercise> list = dbSession.createCriteria(Exercise.class).list();
		Exercise[] exList = new Exercise[list.size()];
		exList = (Exercise[]) list.toArray(exList);
		request.setAttribute("exList", exList);

		return "workoutAdd.jsp";
	}
}
